﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.PlayerAttackAlleyLogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using System.Collections.Generic;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public class PlayerAttackAlleyLogEntry : LogEntry
  {
    [SaveableField(270)]
    public readonly Hero CommonAreaOwner;
    [SaveableField(271)]
    public readonly Settlement Location;

    internal static void AutoGeneratedStaticCollectObjectsPlayerAttackAlleyLogEntry(
      object o,
      List<object> collectedObjects)
    {
      ((LogEntry) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this.CommonAreaOwner);
      collectedObjects.Add((object) this.Location);
    }

    internal static object AutoGeneratedGetMemberValueCommonAreaOwner(object o)
    {
      return (object) ((PlayerAttackAlleyLogEntry) o).CommonAreaOwner;
    }

    internal static object AutoGeneratedGetMemberValueLocation(object o)
    {
      return (object) ((PlayerAttackAlleyLogEntry) o).Location;
    }

    public override CampaignTime KeepInHistoryTime => CampaignTime.Weeks(1f);

    public PlayerAttackAlleyLogEntry(Hero allyOwner, Settlement location)
    {
      this.CommonAreaOwner = allyOwner;
      this.Location = location;
    }

    public override ImportanceEnum GetImportanceForClan(Clan clan)
    {
      return ImportanceEnum.SlightlyImportant;
    }

    public override void GetConversationScoreAndComment(
      Hero talkTroop,
      bool findString,
      out string comment,
      out ImportanceEnum score)
    {
      score = ImportanceEnum.Zero;
      comment = "";
      if (this.CommonAreaOwner == talkTroop)
      {
        score = ImportanceEnum.QuiteImportant;
        if (!findString)
          return;
        comment = "str_comment_common_area_fight_owner";
      }
      else
      {
        if (talkTroop.HomeSettlement != this.Location)
          return;
        score = ImportanceEnum.ReasonablyImportant;
        if (!findString)
          return;
        MBTextManager.SetTextVariable("COMMON_AREA_OWNER", this.CommonAreaOwner.Name, false);
        comment = "str_comment_common_area_fight_other";
      }
    }

    public override string ToString()
    {
      TextObject textObject = new TextObject("{=!}Player attacked to common area of {OWNER_HERO} in {SETTLEMENT}.");
      textObject.SetTextVariable("OWNER_HERO", this.CommonAreaOwner.Name);
      textObject.SetTextVariable("SETTLEMENT", this.Location.Name);
      return textObject.ToString();
    }
  }
}
